﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JMY_Factory
{
    public class DataAccess<T> where T:class
    {
        private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["DAL"];
        private DataAccess() { }
        //创建实例
        public static T CreateDAL(string type)
        {
            string ClassName = string.Format(path+".{0}",type);
            try
            {
                return (T)System.Reflection.Assembly.Load(path).CreateInstance(ClassName);
            }
            catch (Exception ex)
            {

                throw new Exception(ex.Message);
            }
        }
    }
}
